package com.yunji.storage.context;

import com.yunji.base.cache.BaseCache;
import com.yunji.common.utils.bean.BeanUtils;
import com.yunji.storage.domain.AllocateTicketDO;
import com.yunji.storage.vo.AllocateTicketVO;

import java.util.ArrayList;
import java.util.List;

public class AllocateTicketConvert {

    public static List<AllocateTicketVO> domainToVO(List<AllocateTicketDO> list) {
        List<AllocateTicketVO> voList = new ArrayList<>();
        list.forEach(item -> voList.add(domainToVO(item)));
        return voList;
    }

    public static AllocateTicketVO domainToVO(AllocateTicketDO ticket) {
        AllocateTicketVO vo = new AllocateTicketVO();
        BeanUtils.clone(ticket, vo);
        vo.setBelongName(BaseCache.getBelongName(vo.getBelongId()));
        vo.setOutBelongName(BaseCache.getBelongName(vo.getOutBelongId()));
        vo.setIntoBelongName(BaseCache.getBelongName(vo.getIntoBelongId()));
        return vo;
    }
}
